<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/templateList.xhtml">

<ui:define name="body">

	<h2 class="title"><a href="#">Gerenciar Raças</a></h2><br/>
	
		<h:form id="racaForm">
			<h:panelGrid columns="1" rendered="#{identity.hasRole('GERENCIAR_RACAS_GRAVAR')}">
			
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">Nome:</ui:define>
					<h:inputText value="#{manterRacaController.racaEdicao.dscNome}"
						required="true"
						style="width: 300px;"
						maxlength="200"
						onkeydown="Mascara(this,Maiusculo)"
						onkeyup="Mascara(this,Maiusculo)"/>
				</s:decorate>
				
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">Porte:</ui:define>
					<s:decorate template="/layout/editTable.xhtml">
		        		<h:selectOneMenu value="#{manterRacaController.racaEdicao.porte}" required="true">
							<f:selectItem itemLabel="SELECIONE" itemValue=""/>	
							<f:selectItem itemLabel="PEQUENO" itemValue="P"/>
							<f:selectItem itemLabel="MÉDIO" itemValue="M"/>
							<f:selectItem itemLabel="GRANDE" itemValue="G"/>
						</h:selectOneMenu>
					</s:decorate>
				</s:decorate>
				
			</h:panelGrid>
			
			<div class="actionButtons">
	            <h:commandButton id="submit" value="Salvar" action="#{manterRacaController.salvar}"
	            	rendered="#{identity.hasRole('GERENCIAR_RACAS_GRAVAR')}"
	            	onclick="javascript:if(!confirm('Tem certeza que deseja salvar?'))return false;"/>
	        	<a:commandButton id="new" value="Cancelar" action="#{manterRacaController.cancelar}"
	        		rendered="#{identity.hasRole('GERENCIAR_RACAS_GRAVAR')}"
	        		ajaxSingle="true"
	        		reRender="racaForm"/>
	        </div>
		</h:form>
		<br/><br/>		
		<h:form id="racasForm">			
	        <rich:dataTable value="#{manterRacaController.listaRacas}" var="_raca"
	        	rows="10"
	        	id="tabelaRacas">
	        
	        	<rich:column>
	        		<f:facet name="header">
	        			<h:selectBooleanCheckbox value="#{manterRacaController.selecionadoTodos}">
	        				<a:support event="onchange" action="#{manterRacaController.selecionaTodos()}" reRender="tabelaRacas"/>
	        			</h:selectBooleanCheckbox>
	        		</f:facet>
	        		<h:selectBooleanCheckbox value="#{_raca.selecionado}" />
	        	</rich:column>
	        	
	        	<rich:column filterBy="#{_raca.dscNome}" filterEvent="onkeyup">
	        		<f:facet name="header">NOME</f:facet>
	        		<h:outputText value="#{_raca.dscNome}"/>
	        	</rich:column>
	        	
	        	<rich:column>
	        		<f:facet name="header">PORTE</f:facet>
	        		<h:selectOneMenu value="#{_raca.porte}" disabled="true">
						<f:selectItem itemLabel="PEQUENO" itemValue="P"/>
						<f:selectItem itemLabel="MÉDIO" itemValue="M"/>
						<f:selectItem itemLabel="GRANDE" itemValue="G"/>
					</h:selectOneMenu>
	        	</rich:column>
	        	
	        	<rich:column rendered="#{identity.hasRole('GERENCIAR_RACAS_GRAVAR')}">
	        		<f:facet name="header"></f:facet>
	        		<h:commandLink value="EDITAR"
	        			action="#{manterRacaController.editar(_raca)}"/>	
	        	</rich:column>
	        </rich:dataTable>
	        <rich:datascroller for="tabelaRacas"/>
	        <br/>
	        <div class="actionButtons">
	        	<h:commandButton id="remove" value="Excluir" action="#{manterRacaController.excluir}"
	        		rendered="#{identity.hasRole('GERENCIAR_RACAS_EXCLUIR')}"
	        		onclick="javascript:if(!confirm('Tem certeza que deseja excluir a(s) raça(s) selecionada(s)?'))return false;"/>
	        </div>
	        
	    </h:form>

 </ui:define>
</ui:composition>
